package cook.controller;

import cook.request.FridgeGoodsIdRequest;
import cook.request.FridgeGoodsModRequest;
import cook.request.FridgeGoodsRequest;
import cook.request.FridgeIdRequest;
import cook.service.FridgeGoodsService;
import cook.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 冰箱里的食材表 前端控制器
 * </p>
 *
 * @author 爱计算机的小天才
 * @since 2023-03-29
 */
@RestController
@RequestMapping("/api/fridge_goods/v1/")
public class FridgeGoodsController {

    @Autowired(required = false)
    private FridgeGoodsService fridgeGoodsService;

    // 添加食材
    @PostMapping("add")
    public JsonData add(@RequestBody FridgeGoodsRequest fridgeGoodsRequest) {
        return fridgeGoodsService.add(fridgeGoodsRequest);
    }

    // 删除食材
    @PostMapping("del")
    public JsonData del(@RequestBody FridgeGoodsIdRequest fridgeGoodsIdRequest) {
        return fridgeGoodsService.del(fridgeGoodsIdRequest);
    }

    /**
     * 修改食材
     */
    @PostMapping("mod")
    public JsonData mod(@RequestBody FridgeGoodsModRequest fridgeGoodsModRequest) {
        return fridgeGoodsService.mod(fridgeGoodsModRequest);
    }
    // 查询食材详情
    @PostMapping("detail")
    public JsonData detail(@RequestBody FridgeGoodsIdRequest fridgeGoodsIdRequest) {
        return fridgeGoodsService.detail(fridgeGoodsIdRequest);
    }

    // 查询食材列表
    @PostMapping("list")
    public JsonData list(@RequestBody FridgeIdRequest fridgeIdRequest) {
        return fridgeGoodsService.list(fridgeIdRequest);
    }

}

